{% for message in messages %}
std::string toString(const {{message["name"]}} &data)
{
    std::stringstream ss;
    ss << "{{message["name"]}} {\n";
    {% for field in message["fields"] %}
    {% if field["type"] not in type_list %}
    ss << "{{field["name"]}} : " << data.{{field["name"]}}.toString() << std::endl;
    {% elif field["repeated"] == True %}
    for(auto &item : data.{{field["name"]}}){
        ss << item << "  ";
    }
    ss << std::endl;
    {% else %}
    ss << "{{field["name"]}} : " << data.{{field["name"]}} << std::endl;
    {% endif %}
    {% endfor %}
    ss << "}\n";
    return ss.str();
}
{% endfor %}